import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Vector;



public class DirInfo {
	Vector<String> directorys;
	Vector<String> files;
	public DirInfo()
	{
		directorys = new Vector<String>();
		files = new Vector<String>();
	}
	
	public boolean hasDir(String name)
	{
		return directorys.contains(name);
	}
	public boolean resolveLSFile(File file)
	{
		System.out.println("resolveLSFile:" + file.getAbsolutePath());
		directorys.clear();
		files.clear();
		BufferedReader reader = null;
        try {
            reader = new BufferedReader(new FileReader(file));
            String tempName = null;
            while ((tempName = reader.readLine()) != null) {
            	String tempType = reader.readLine();
            	if(tempType == null)
            		return false;
            	if(tempType.equals("1"))
            		directorys.add(tempName);
            	else if(tempType.equals("2"))
            		files.add(tempName);
            	//System.out.println("name:" + tempName + "\n type:" + tempType);
            }
            reader.close();
            return true;
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (reader != null) {
                try {
                    reader.close();
                } catch (IOException e1) {
                }
            }
        }
        return false;
	}
	public void display() {
		System.out.println("<DIR>\t.");
		System.out.println("<DIR>\t..");
		for(String d : directorys)
		{
			System.out.println("<DIR>\t" + d);
		}
		for(String f: files)
		{
			System.out.println("\t" + f);
		}
	}
}
